#include <iostream> 
#include <set> 
using namespace std;

int main(){
	int m;
	cin >> m;
	for(int i=0; i<m; i++){
		int n;
		cin >> n;
		int max = 0,cnt = 0;
		set<pair<int,int> > SET;
		for(int i=0; i<n; i++){
			cout << "99999";
			set<pair<int,int> > input;
			cout << "88888";
			int k;
			cin >> k;
			for(int i=0; i<k; i++){
				int v1, v2;
				cin >> v1 >> v2;
				input.insert(make_pair(v1,v2));
			}
			if( SET.empty() ){
				SET = input;
				if( cnt>max ) max = cnt;
				cnt = 0;
			}else{
				set<pair<int,int> >::iterator p = SET.cbegin();
				for(auto pp=input.begin(); pp!=input.end(); pp++) cout << (*pp).first << (*pp).second<<endl;
				for(int i=0; i<SET.size(); i++){
					cout << "**"<<SET[i].first << SET[i].second<<endl;
					if( input.find(SET[i])==input.end() ) {

						SET.erase(SET[i]);
						cout << "not find";
						
						//if( --p==SET.cend() ) cout << "eeee";
					//	cout << "**"<<(*p).first << (*p).second<<endl;
					}
				}	
				cnt++;
				for(auto p = SET.begin(); p!=SET.end(); p++){
					cout << (*p).first << " " << (*p).second << endl;
				}
			}
			cout << "--";
		}
		//cout << max << endl;	
		cout << "++";	
	}
	return 0;
}
